import axios from "axios";
export default {
    get(curpage, eachPage) {
        return axios
            .get('/order', {
                params: {
                    curpage, eachPage
                }
            })
            .then(function (response) {
                return response.data
            })
    },
    getDistribution(id) {
        return axios
            .get("/order/getDistribution", {
                params: {
                    id,
                },
            })
            .then(function (response) {
                return response.data;
            });
    },
    addOrders(data) {
        const { users, stores, distribution, goodsArr, price, resource } = data;
        const userId = users;
        const shopId = stores;
        const distributionId = distribution;
        const state = resource;
        return axios
            .post("/order/addOrders", {
                userId,
                shopId,
                distributionId,
                goodsArr,
                state,
                price
            })
            .then(function (response) {
                return response.data;
            })
            .catch(function (error) {
                console.log(error);
            });
    },
    searchOrder: (_id) => {
        return axios
            .post("/order/searchOrder", {
                _id
            })
            .then(function (response) {
                return response.data
            })
    },
}
